﻿
using Dapper;
using HBase;
using hCommand;
using Net.http;
using Persistence;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Transactions;

namespace Persistence {
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：Component                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2020/9/2 11:28:16                        
   *└────────────────────────────────────────────────┘
   **/
    public class StatUtil {
        static public void stock(Sw sw, long stockId) {
            /*
                string sql = @"update Core_stock set  d_Count=(select  IFNULL(  sum(Count_db),0) from core_stock_det where pid=@stockId and status>0) where id=@stockId ";
                sql = HUtil.formatInt(sql, StockDetailStatus.库存, StockDetailStatus.待盘库);
                conn.Execute(sql, new { stockId }, trans);
            */
        }
             
        public static void  cvCSDIn(Sw sw, List<CoreStockDet> csds) {
            List<long> doiDetIdlist = new List<long>();
            foreach (CoreStockDet csd in csds) {
                doiDetIdlist.Add(csd.doiDetId);
            }
            if (doiDetIdlist.Count > 0) {
                sw.exec("update wh_doi_det set cv=cv+1 where id in @doiDetIdlist", new { doiDetIdlist });
            }
            
        }
        public static void cvCSDOut(Sw sw, List<CoreStockDet> csds) { 
            List<long> dooDetIdlist = new List<long>(); 
            foreach (CoreStockDet csd in csds) { 
                dooDetIdlist.Add(csd.dooDetId);
            } 
            if (dooDetIdlist.Count > 0) {
                sw.exec("update wh_doo_det set cv=cv+1 where id in @dooDetIdlist", new { dooDetIdlist });
            } 
        }
        public static void changeBatch(Sw sw, List<CoreStockDet> csds) {
            List<long> batchIds = new List<long>(); 
            foreach (CoreStockDet csd in csds) {
                if (batchIds.Contains(csd.batchId)) {
                    batchIds.Add(csd.batchId);
                }
            }
            if (batchIds.Count > 0) {
                sw.exec("update wh_batch set cv=cv+1 where id  in @batchIds", new { batchIds });
            }
        }
    
       
    }
}
